using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using StillDesign.PhysX;

namespace Programonica.Igramonica.Physics
{
    public class ControllerHitReport : UserControllerHitReport
    {
        public ControllerHitReport(Scene scene) : base()
        {
        }

        public override ControllerAction OnShapeHit(ControllerShapeHit hit)
        {
            if (hit.Shape != null)
            {
                GameGroup group = (GameGroup)hit.Shape.Group;

                Actor actor = hit.Shape.Actor;

                if (group != GameGroup.GROUP_COLLIDABLE_NON_PUSHABLE)
                {
                    if (actor.IsDynamic)
                    {
                        if (hit.MotionDirection.Y == 0.0f)
                        {
                            float coeff = actor.Mass*hit.MotionLength*10.0f;

                            actor.AddForceAtLocalPosition(hit.MotionDirection * coeff, Vector3.Zero, ForceMode.Impulse, true);
                        }
                    }
                }
            }

            return ControllerAction.None;
        }

        public override ControllerAction OnControllerHit(ControllersHit hit)
        {
            return ControllerAction.None;
        }
    }
}
